#include <g-bios.h>
#include <flash/part.h>


static int main(int argc, char *argv[])
{ 
	BYTE *pLoadAddr;
	int nLoadLen;
	struct Partition *pPart;
	int nLen;
	BYTE * pBuff;


	if ((pPart = GuPartOpenCur()) == NULL)
	{
		return -EINVAL;
	}

	pBuff = malloc(MB(3)); // fixme!
	if (pBuff == NULL)
	{
		printf("%s(), line %d\n", __FUNCTION__, __LINE__);
		return -ENOMEM;
	}

	nLen = GuSerialLoad(pBuff);
	// if nLen < 0

	GuPartWrite(pPart, pBuff, nLen);

	free(pBuff);

	GuPartSetImgInfo(pPart, "(Unknown kermit)", nLen);

	GuPartClose(pPart);

	GuSysConfStore();

	return nLoadLen;
}


INSTALL_APPLICATION(kermit, main, "download file via kermit");

